package com.utilities;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SQLConnection {
	private Connection conn = null;
	
	private String url;
	private String user;
	private String password;
	private String driver;
	
	public SQLConnection(String url, String user, String password, String driver) {
		//super();
		this.url = url;
		this.user = user;
		this.password = password;
		this.driver = driver;
	}
	
	public Connection getConnection(){
		try {
			// This will load the MySQL driver, each DB has its own driver
			Class.forName(driver);
		
			// Create a connection to the database
			conn = DriverManager.getConnection(url,user,password);
		} catch (ClassNotFoundException e) {
			// Could not find the database driver
			System.out.println("ClassNotFoundException : "+e.getMessage());
		
		} catch (SQLException e) {
		
			// Could not connect to the database
			System.out.println(e.getMessage());
		}
		
	return conn;
	}
		
}
